package br.feevale.jogo.model;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import br.feevale.jogo.util.AgenteEnum;

@SuppressWarnings("serial")
public class Casa extends JPanel {
	
	private Integer id;
	private AgenteEnum agente;
	private Integer column;
	private Integer row;
	private Boolean habilitado;
	private JLabel label;
	
	public Casa() {
		setAlignmentX(CENTER_ALIGNMENT);
		setAlignmentY(CENTER_ALIGNMENT);
	}
	
	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	public AgenteEnum getAgente() {
		return agente;
	}
	
	public void setAgente(AgenteEnum agente) {
		this.agente = agente;
		
		if (AgenteEnum.GANSO.equals(agente)) {
			Icon iconGanso = new ImageIcon(getClass().getClassLoader().getResource("br/feevale/jogo/resources/chiken.jpg"));
			add(new JLabel(iconGanso));
		} else if (AgenteEnum.RAPOSA.equals(agente)) {
			Icon iconRaposa = new ImageIcon(getClass().getClassLoader().getResource("br/feevale/jogo/resources/fox.jpg"));
			add(new JLabel(iconRaposa));
		} else {
			removeAll();
		}
		
		repaint();
		revalidate();
	}
	
	public Integer getColumn() {
		return column;
	}
	
	public void setColumn(Integer column) {
		this.column = column;
	}
	
	public Integer getRow() {
		return row;
	}
	
	public void setRow(Integer row) {
		this.row = row;
	}
	
	public Boolean getHabilitado() {
		return habilitado;
	}

	public void setHabilitado(Boolean habilitado) {
		this.habilitado = habilitado;
	}

	public JLabel getLabel() {
		return label;
	}

	public void setLabel(JLabel label) {
		this.label = label;
	}
	
	public String getPosicaoCommand() {
		return row + "," + column;
	}
	
}
